import fetch from 'common/src/utils/fetch';
import UTILS from "common/src/utils/utils";

/**
 * 预览点名册
 */
function previewRollBookList(teachingClassId, calendarId) {
    return fetch({
        url:
            '/api/electionservice/reportManagement/previewRollBookList?teachingClassId=' +
            teachingClassId +
            '&calendarId=' +
            calendarId,
        method: 'get'
    });
}
function previewGraduateRollBookList(teachingClassId, calendarId) {//预览点名册（研究生）
    return fetch({
        url:
            '/api/electionservice/reportManagement/previewGraduteRollBook?teachingClassId=' +
            teachingClassId,
        method: 'get'
    });
}

/**
 * 导出
 */
function exportRollBookList(data) {
    return fetch({
        url: '/api/electionservice/reportManagement/exportRollBookList',
        method: 'post',
        data: data
    });
}

/**
 * 选课日志导出
 */
function exportCourseLog(data) {
    return fetch({
        url: '/api/electionservice/elcLog/exportElclog',
        method: 'post',
        data: data
    });
}

function exportGraduteRollBookList(data) {//研究生点名册的导出1
    return fetch({
        url: `/api/electionservice/reportManagement/exportGraduteRollBookList`,
        method: 'post',
        data: data,
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, '点名册.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}
function exportGraduteRollBookListNew(data) {//研究生点名册的导出2
    return fetch({
        url: `/api/electionservice/reportManagement/exportGraduteRollBookListNew`,
        method: 'post',
        data: data,
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, '点名册.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}
function exportGraduteDownList(data){//研究生点名册下载
    return fetch({
        url: `/api/electionservice/reportManagement/exportGraduteRollBookList3`,
        method: 'post',
        data: data,
    })
}
function downStatus(key) {
    return fetch({
        url: '/api/electionservice/reportManagement/resultWithOutPre/' + key,
        method: 'get'
    });
}

function exportGraduteRollBook(data) {//研究生点名册详情导出2
    return fetch({
        url: `/api/electionservice/reportManagement/exportGraduteRollBook`,
        method: 'post',
        data: data,
        responseType:'blob'
    }).then(res => {
        UTILS.downloadFile(res, '点名册详情.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}


/**
 *
 * 查询是否导出完成
 */
function exportStatus(key) {
    return fetch({
        url: '/api/electionservice/reportManagement/result/'+key,
        method: 'get'
    });
}

/**
 *
 * 导出预览点名册
 */
function exportPreRollBookList(data) {
    return fetch({
        url: '/api/electionservice/reportManagement/exportPreRollBookList',
        method: 'post',
        data: data,
        responseType: 'blob'
    }).then(res => {
        UTILS.downloadFile(res, 'DianMingCe.xls', 'application/vnd.ms-excel;charset=utf-8');
    });
}


export default {
    findRollBookListUrl: '/api/electionservice/reportManagement/findRollBookList',
    findGraduteRollBookList:'/api/electionservice/reportManagement/findGraduteRollBookList',//研究生点名册
    findGraduteRollBookListNew: '/api/electionservice/reportManagement/findGraduteRollBookListNew',
    previewRollBookList: previewRollBookList,
    exportRollBookList: exportRollBookList,
    exportStatus:exportStatus,
    exportPreRollBookList:exportPreRollBookList,
    exportGraduteRollBookList:exportGraduteRollBookList,//研究生导出1
    previewGraduateRollBookList,//研究生预览点名册
    exportGraduteDownList,//研究生点名册下载
    downStatus,
    exportGraduteRollBook,//研究生点名册详情导出2
    exportCourseLog,
    exportGraduteRollBookListNew: exportGraduteRollBookListNew
};
